import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
} from "typeorm";
import { User } from "./User";

@Entity()
export class Article {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  author: string;

  @Column({ default: "" })
  articleTitle: string;

  @Column({ default: "" })
  articleContent: string;

  @Column({ default: "default" })
  classification: string;

  @CreateDateColumn({
    name: "create_time",
    nullable: true,
  })
  createTime: Date;

  @UpdateDateColumn({
    name: "update_time",
    nullable: true,
  })
  updateTime: Date | null;

  @ManyToOne(() => User, (user) => user.article)
  user: User;
}
